#include <list>
#include <string>

#include "doctype_definition.h"
#include "base_element.h"

using namespace std;

DoctypeDefinition::DoctypeDefinition () {
	declaredElements = new map<string,BaseElement*>();
}

DoctypeDefinition::~DoctypeDefinition () {
}

BaseElement* DoctypeDefinition::getElementByName(const string &aName) {
	map<string,BaseElement*>::iterator it;
	it = declaredElements->find(aName);
	if (it != declaredElements->end()) {
    	return (*declaredElements)[aName];
	} else {
		return NULL;
	}
}

void DoctypeDefinition::addDeclaration(string &aName, BaseElement *aElem) {
	(*declaredElements)[aName] = aElem;
	//declaredElements->insert ( pair<string,BaseElement*>(aName,aElem) );
}

void DoctypeDefinition::print(std::ostream& out) {
	for (map<string, BaseElement*>::iterator it = declaredElements->begin();
	     it != declaredElements->end();
	     ++it) {
    	it->second->print(out);
    }
}
